<?php
namespace Apps\BoxEdu\Model;

use Think\Model;

class EduClassroomsModel extends \BaseModel
{
    public function load($id = "")
    {
        $data = $this->find($id);
        if (!$data) {
            return false;
        }
        $classrooms_subject = BoxModel("edu_classrooms_subject")->get("class_room_id='$id'");
        // dump($classrooms_subject);
        foreach ($classrooms_subject as $one) {
            $setting[$one['week']] = array(
                'date' => $one['date'],
                'week' => $one['week'],
                'week_str' => $one['week_str'],
            );
            $data_week[$one['week']][$one['id']] = $one;
            $setting[$one['week']]['data'][$one['id']] = $one;
        }

        foreach ($setting as $k => $one) {
            $setting[$k]['data'] = $data_week[$k];
        }
        $data['setting'] = $setting;
        $data['encode_setting'] = json_encode($setting);
        ///$setting=json_decode($data['setting'],true);
        foreach ($setting as $k => $one1) {
            foreach ($one1['data'] as $one) {
                $subject_data = BoxModel("edu_offline_subject")->load($one1['offline_subject_id']);
                $one['subject'] = $subject_data['name'];
                $one['week_str'] = $one1['week_str'];
                $data['setting_decode'][$one['id']] = $one;
            }
        }

        $data['area'] = BoxModel("SystemArea")->load($data['province_id']);
        $data['school'] = BoxModel("EduSchools")->load($data['school_id']);

        return $data;
    }


}
 